home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / Power.h < prev    next >
Text File  |  1995-07-06  |  15KB  |  503 lines

  1. /*
  2.      File:        Power.h
  3.  
  4.      Contains:    Power Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __POWER__
  21. #define __POWER__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __MIXEDMODE__
  30. #include <MixedMode.h>
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if PRAGMA_ALIGN_SUPPORTED
  38. #pragma options align=mac68k
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT_SUPPORTED
  42. #pragma import on
  43. #endif
  44.  
  45.  
  46. enum {
  47. /* Bit positions for ModemByte */
  48.     modemOnBit                    = 0,
  49.     ringWakeUpBit                = 2,
  50.     modemInstalledBit            = 3,
  51.     ringDetectBit                = 4,
  52.     modemOnHookBit                = 5,
  53. /* masks for ModemByte */
  54.     modemOnMask                    = 0x01,
  55.     ringWakeUpMask                = 0x04,
  56.     modemInstalledMask            = 0x08,
  57.     ringDetectMask                = 0x10,
  58.     modemOnHookMask                = 0x20,
  59. /* bit positions for BatteryByte */
  60.     chargerConnBit                = 0,
  61.     hiChargeBit                    = 1,
  62.     chargeOverFlowBit            = 2,
  63.     batteryDeadBit                = 3,
  64.     batteryLowBit                = 4,
  65.     connChangedBit                = 5,
  66. /* masks for BatteryByte */
  67.     chargerConnMask                = 0x01,
  68.     hiChargeMask                = 0x02,
  69.     chargeOverFlowMask            = 0x04,
  70.     batteryDeadMask                = 0x08,
  71.     batteryLowMask                = 0x10,
  72.     connChangedMask                = 0x20
  73. };
  74.  
  75. enum {
  76. /* commands to SleepQRec sleepQProc */
  77.     sleepRequest                = 1,
  78.     sleepDemand                    = 2,
  79.     sleepWakeUp                    = 3,
  80.     sleepRevoke                    = 4,
  81.     sleepUnlock                    = 4,
  82.     sleepDeny                    = 5,
  83.     sleepNow                    = 6,
  84.     dozeDemand                    = 7,
  85.     dozeWakeUp                    = 8,
  86.     dozeRequest                    = 9,
  87. /* SleepQRec.sleepQFlags */
  88.     noCalls                        = 1,
  89.     noRequest                    = 2,
  90.     slpQType                    = 16,
  91.     sleepQType                    = 16
  92. };
  93.  
  94. /* bits in bitfield returned by PMFeatures */
  95. enum {
  96.     hasWakeupTimer                = 0,                            /* 1=wakeup timer is supported                        */
  97.     hasSharedModemPort            = 1,                            /* 1=modem port shared by SCC and internal modem    */
  98.     hasProcessorCycling            = 2,                            /* 1=processor cycling is supported                    */
  99.     mustProcessorCycle            = 3,                            /* 1=processor cycling should not be turned off        */
  100.     hasReducedSpeed                = 4,                            /* 1=processor can be started up at reduced speed    */
  101.     dynamicSpeedChange            = 5,                            /* 1=processor speed can be switched dynamically    */
  102.     hasSCSIDiskMode                = 6,                            /* 1=SCSI Disk Mode is supported                    */
  103.     canGetBatteryTime            = 7,                            /* 1=battery time can be calculated                    */
  104.     canWakeupOnRing                = 8,                            /* 1=can wakeup when the modem detects a ring        */
  105.     hasDimmingSupport            = 9,                            /* 1=has dimming support built in                    */
  106.     hasStartupTimer                = 10                            /* 1=startup timer is supported                        */
  107. };
  108.  
  109. /* bits in bitfield returned by GetIntModemInfo and set by SetIntModemState */
  110. enum {
  111.     hasInternalModem            = 0,                            /* 1=internal modem installed                        */
  112.     intModemRingDetect            = 1,                            /* 1=internal modem has detected a ring                */
  113.     intModemOffHook                = 2,                            /* 1=internal modem is off hook                        */
  114.     intModemRingWakeEnb            = 3,                            /* 1=wakeup on ring is enabled                        */
  115.     extModemSelected            = 4,                            /* 1=external modem selected                        */
  116.     modemSetBit                    = 15                            /* 1=set bit, 0=clear bit (SetIntModemState)        */
  117. };
  118.  
  119. /* bits in BatteryInfo.flags                                     */
  120. /* ("chargerConnected" doesn't mean the charger is plugged in)    */
  121. enum {
  122.     batteryInstalled            = 7,                            /* 1=battery is currently connected                    */
  123.     batteryCharging                = 6,                            /* 1=battery is being charged                        */
  124.     chargerConnected            = 5                                /* 1=charger is connected to the PowerBook            */
  125. };
  126.  
  127. enum {
  128.     HDPwrQType                    = 'HD',                            /* hard disk spindown queue element type            */
  129.     PMgrStateQType                = 'PM'
  130. };
  131.  
  132. typedef struct BatteryInfo BatteryInfo;
  133.  
  134. struct BatteryInfo {
  135.     UInt8                            flags;                        /* misc flags (see below)                            */
  136.     UInt8                            warningLevel;                /* scaled warning level (0-255)                        */
  137.     UInt8                            reserved;                    /* reserved for internal use                        */
  138.     UInt8                            batteryLevel;                /* scaled battery level (0-255)                        */
  139. };
  140. typedef SInt8 ModemByte;
  141.  
  142. typedef SInt8 BatteryByte;
  143.  
  144. typedef long PMResultCode;
  145.  
  146. typedef struct SleepQRec SleepQRec, *SleepQRecPtr;
  147.  
  148. typedef struct HDQueueElement HDQueueElement;
  149.  
  150. /*
  151.         SleepQProcPtr uses register based parameters on the 68k and cannot
  152.         be written in or called from a high-level language without the help of
  153.         mixed mode or assembly glue.
  154.  
  155.             typedef pascal long (*SleepQProcPtr)(long message, SleepQRecPtr qRecPtr);
  156.  
  157.         In:
  158.          => message         D0.L
  159.          => qRecPtr         A0.L
  160.         Out:
  161.          <= return value    D0.L
  162. */
  163. typedef pascal void (*HDSpindownProcPtr)(HDQueueElement *theElement);
  164.  
  165. #if GENERATINGCFM
  166. typedef UniversalProcPtr SleepQUPP;
  167. typedef UniversalProcPtr HDSpindownUPP;
  168. #else
  169. typedef Register68kProcPtr SleepQUPP;
  170. typedef HDSpindownProcPtr HDSpindownUPP;
  171. #endif
  172.  
  173. struct SleepQRec {
  174.     struct SleepQRec                *sleepQLink;                /* pointer to next queue element                */
  175.     short                            sleepQType;                    /* queue element type (must be SleepQType)        */
  176.     SleepQUPP                        sleepQProc;                    /* pointer to sleep universal proc ptr            */
  177.     short                            sleepQFlags;                /* flags                                        */
  178. };
  179. struct HDQueueElement {
  180.     struct HDQueueElement            *hdQLink;                    /* pointer to next queue element                */
  181.     short                            hdQType;                    /* queue element type (must be HDPwrQType)        */
  182.     short                            hdFlags;                    /* miscellaneous flags                            */
  183.     HDSpindownUPP                    hdProc;                        /* pointer to routine to call                    */
  184.     long                            hdUser;                        /* user-defined (variable storage, etc.)        */
  185. };
  186. typedef struct BatteryTimeRec BatteryTimeRec;
  187.  
  188. struct BatteryTimeRec {
  189.     unsigned long                    expectedBatteryTime;        /* estimated battery time remaining (seconds)    */
  190.     unsigned long                    minimumBatteryTime;            /* minimum battery time remaining (seconds)        */
  191.     unsigned long                    maximumBatteryTime;            /* maximum battery time remaining (seconds)        */
  192.     unsigned long                    timeUntilCharged;            /* time until battery is fully charged (seconds)*/
  193. };
  194. typedef struct WakeupTime WakeupTime;
  195.  
  196. struct WakeupTime {
  197.     unsigned long                    wakeTime;                    /* wakeup time (same format as current time)        */
  198.     Boolean                            wakeEnabled;                /* 1=enable wakeup timer, 0=disable wakeup timer    */
  199.     SInt8                            filler;
  200. };
  201. typedef struct StartupTime StartupTime;
  202.  
  203. struct StartupTime {
  204.     unsigned long                    startTime;                    /* startup time (same format as current time)        */
  205.     Boolean                            startEnabled;                /* 1=enable startup timer, 0=disable startup timer    */
  206.     SInt8                            filler;
  207. };
  208. extern pascal OSErr DisableWUTime(void);
  209. extern pascal OSErr SetWUTime(long WUTime);
  210. extern pascal OSErr GetWUTime(long *WUTime, Byte *WUFlag);
  211. extern pascal OSErr BatteryStatus(Byte *Status, Byte *Power);
  212. extern pascal OSErr ModemStatus(Byte *Status);
  213.  
  214. #if !GENERATINGCFM
  215. #pragma parameter __D0 IdleUpdate
  216. #endif
  217. extern pascal long IdleUpdate(void)
  218.  ONEWORDINLINE(0xA285);
  219.  
  220. #if !GENERATINGCFM
  221. #pragma parameter __D0 GetCPUSpeed
  222. #endif
  223. extern pascal long GetCPUSpeed(void)
  224.  TWOWORDINLINE(0x70FF, 0xA485);
  225. extern pascal void EnableIdle(void)
  226.  TWOWORDINLINE(0x7000, 0xA485);
  227. extern pascal void DisableIdle(void)
  228.  TWOWORDINLINE(0x7001, 0xA485);
  229.  
  230. #if !GENERATINGCFM
  231. #pragma parameter SleepQInstall(__A0)
  232. #endif
  233. extern pascal void SleepQInstall(SleepQRecPtr qRecPtr)
  234.  ONEWORDINLINE(0xA28A);
  235.  
  236. #if !GENERATINGCFM
  237. #pragma parameter SleepQRemove(__A0)
  238. #endif
  239. extern pascal void SleepQRemove(SleepQRecPtr qRecPtr)
  240.  ONEWORDINLINE(0xA48A);
  241. extern pascal void AOn(void)
  242.  TWOWORDINLINE(0x7004, 0xA685);
  243. extern pascal void AOnIgnoreModem(void)
  244.  TWOWORDINLINE(0x7005, 0xA685);
  245. extern pascal void BOn(void)
  246.  TWOWORDINLINE(0x7000, 0xA685);
  247. extern pascal void AOff(void)
  248.  TWOWORDINLINE(0x7084, 0xA685);
  249. extern pascal void BOff(void)
  250.  TWOWORDINLINE(0x7080, 0xA685);
  251. /* Public Power Management API (NEW!) */
  252.  
  253. #if !GENERATINGCFM
  254. #pragma parameter __D0 PMSelectorCount
  255. #endif
  256. extern pascal short PMSelectorCount(void)
  257.  TWOWORDINLINE(0x7000, 0xA09E);
  258.  
  259. #if !GENERATINGCFM
  260. #pragma parameter __D0 PMFeatures
  261. #endif
  262. extern pascal unsigned long PMFeatures(void)
  263.  TWOWORDINLINE(0x7001, 0xA09E);
  264.  
  265. #if !GENERATINGCFM
  266. #pragma parameter __D0 GetSleepTimeout
  267. #endif
  268. extern pascal UInt8 GetSleepTimeout(void)
  269.  TWOWORDINLINE(0x7002, 0xA09E);
  270.  
  271. #if !GENERATINGCFM
  272. #pragma parameter SetSleepTimeout(__D0)
  273. #endif
  274. extern pascal void SetSleepTimeout(UInt8 timeout)
  275.  FOURWORDINLINE(0x4840, 0x303C, 0x0003, 0xA09E);
  276.  
  277. #if !GENERATINGCFM
  278. #pragma parameter __D0 GetHardDiskTimeout
  279. #endif
  280. extern pascal UInt8 GetHardDiskTimeout(void)
  281.  TWOWORDINLINE(0x7004, 0xA09E);
  282.  
  283. #if !GENERATINGCFM
  284. #pragma parameter SetHardDiskTimeout(__D0)
  285. #endif
  286. extern pascal void SetHardDiskTimeout(UInt8 timeout)
  287.  FOURWORDINLINE(0x4840, 0x303C, 0x0005, 0xA09E);
  288.  
  289. #if !GENERATINGCFM
  290. #pragma parameter __D0 HardDiskPowered
  291. #endif
  292. extern pascal Boolean HardDiskPowered(void)
  293.  TWOWORDINLINE(0x7006, 0xA09E);
  294.  
  295. #if !GENERATINGCFM
  296. #pragma parameter SpinDownHardDisk
  297. #endif
  298. extern pascal void SpinDownHardDisk(void)
  299.  TWOWORDINLINE(0x7007, 0xA09E);
  300.  
  301. #if !GENERATINGCFM
  302. #pragma parameter __D0 IsSpindownDisabled
  303. #endif
  304. extern pascal Boolean IsSpindownDisabled(void)
  305.  TWOWORDINLINE(0x7008, 0xA09E);
  306.  
  307. #if !GENERATINGCFM
  308. #pragma parameter SetSpindownDisable(__D0)
  309. #endif
  310. extern pascal void SetSpindownDisable(Boolean setDisable)
  311.  FOURWORDINLINE(0x4840, 0x303C, 0x0009, 0xA09E);
  312.  
  313. #if !GENERATINGCFM
  314. #pragma parameter __D0 HardDiskQInstall(__A0)
  315. #endif
  316. extern pascal OSErr HardDiskQInstall(HDQueueElement *theElement)
  317.  TWOWORDINLINE(0x700A, 0xA09E);
  318.  
  319. #if !GENERATINGCFM
  320. #pragma parameter __D0 HardDiskQRemove(__A0)
  321. #endif
  322. extern pascal OSErr HardDiskQRemove(HDQueueElement *theElement)
  323.  TWOWORDINLINE(0x700B, 0xA09E);
  324.  
  325. #if !GENERATINGCFM
  326. #pragma parameter GetScaledBatteryInfo(__D0, __A0)
  327. #endif
  328. extern pascal void GetScaledBatteryInfo(short whichBattery, BatteryInfo *theInfo)
  329.  FIVEWORDINLINE(0x4840, 0x303C, 0x000C, 0xA09E, 0x2080);
  330.  
  331. #if !GENERATINGCFM
  332. #pragma parameter AutoSleepControl(__D0)
  333. #endif
  334. extern pascal void AutoSleepControl(Boolean enableSleep)
  335.  FOURWORDINLINE(0x4840, 0x303C, 0x000D, 0xA09E);
  336.  
  337. #if !GENERATINGCFM
  338. #pragma parameter __D0 GetIntModemInfo
  339. #endif
  340. extern pascal unsigned long GetIntModemInfo(void)
  341.  TWOWORDINLINE(0x700E, 0xA09E);
  342.  
  343. #if !GENERATINGCFM
  344. #pragma parameter SetIntModemState(__D0)
  345. #endif
  346. extern pascal void SetIntModemState(short theState)
  347.  FOURWORDINLINE(0x4840, 0x303C, 0x000F, 0xA09E);
  348.  
  349. #if !GENERATINGCFM
  350. #pragma parameter __D0 MaximumProcessorSpeed
  351. #endif
  352. extern pascal short MaximumProcessorSpeed(void)
  353.  TWOWORDINLINE(0x7010, 0xA09E);
  354.  
  355. #if !GENERATINGCFM
  356. #pragma parameter __D0 CurrentProcessorSpeed
  357. #endif
  358. extern pascal short CurrentProcessorSpeed(void)
  359.  TWOWORDINLINE(0x7011, 0xA09E);
  360.  
  361. #if !GENERATINGCFM
  362. #pragma parameter __D0 FullProcessorSpeed
  363. #endif
  364. extern pascal Boolean FullProcessorSpeed(void)
  365.  TWOWORDINLINE(0x7012, 0xA09E);
  366.  
  367. #if !GENERATINGCFM
  368. #pragma parameter __D0 SetProcessorSpeed(__D0)
  369. #endif
  370. extern pascal Boolean SetProcessorSpeed(Boolean fullSpeed)
  371.  FOURWORDINLINE(0x4840, 0x303C, 0x0013, 0xA09E);
  372.  
  373. #if !GENERATINGCFM
  374. #pragma parameter __D0 GetSCSIDiskModeAddress
  375. #endif
  376. extern pascal short GetSCSIDiskModeAddress(void)
  377.  TWOWORDINLINE(0x7014, 0xA09E);
  378.  
  379. #if !GENERATINGCFM
  380. #pragma parameter SetSCSIDiskModeAddress(__D0)
  381. #endif
  382. extern pascal void SetSCSIDiskModeAddress(short scsiAddress)
  383.  FOURWORDINLINE(0x4840, 0x303C, 0x0015, 0xA09E);
  384.  
  385. #if !GENERATINGCFM
  386. #pragma parameter GetWakeupTimer(__A0)
  387. #endif
  388. extern pascal void GetWakeupTimer(WakeupTime *theTime)
  389.  TWOWORDINLINE(0x7016, 0xA09E);
  390.  
  391. #if !GENERATINGCFM
  392. #pragma parameter SetWakeupTimer(__A0)
  393. #endif
  394. extern pascal void SetWakeupTimer(WakeupTime *theTime)
  395.  TWOWORDINLINE(0x7017, 0xA09E);
  396.  
  397. #if !GENERATINGCFM
  398. #pragma parameter __D0 IsProcessorCyclingEnabled
  399. #endif
  400. extern pascal Boolean IsProcessorCyclingEnabled(void)
  401.  TWOWORDINLINE(0x7018, 0xA09E);
  402.  
  403. #if !GENERATINGCFM
  404. #pragma parameter EnableProcessorCycling(__D0)
  405. #endif
  406. extern pascal void EnableProcessorCycling(Boolean enable)
  407.  FOURWORDINLINE(0x4840, 0x303C, 0x0019, 0xA09E);
  408.  
  409. #if !GENERATINGCFM
  410. #pragma parameter __D0 BatteryCount
  411. #endif
  412. extern pascal short BatteryCount(void)
  413.  TWOWORDINLINE(0x701A, 0xA09E);
  414.  
  415. #if !GENERATINGCFM
  416. #pragma parameter __D0 GetBatteryVoltage(__D0)
  417. #endif
  418. extern pascal Fixed GetBatteryVoltage(short whichBattery)
  419.  FOURWORDINLINE(0x4840, 0x303C, 0x001B, 0xA09E);
  420.  
  421. #if !GENERATINGCFM
  422. #pragma parameter GetBatteryTimes(__D0, __A0)
  423. #endif
  424. extern pascal void GetBatteryTimes(short whichBattery, BatteryTimeRec *theTimes)
  425.  FOURWORDINLINE(0x4840, 0x303C, 0x001C, 0xA09E);
  426.  
  427. #if !GENERATINGCFM
  428. #pragma parameter __D0 GetDimmingTimeout
  429. #endif
  430. extern pascal UInt8 GetDimmingTimeout(void)
  431.  TWOWORDINLINE(0x701D, 0xA09E);
  432.  
  433. #if !GENERATINGCFM
  434. #pragma parameter SetDimmingTimeout(__D0)
  435. #endif
  436. extern pascal void SetDimmingTimeout(UInt8 timeout)
  437.  FOURWORDINLINE(0x4840, 0x303C, 0x001E, 0xA09E);
  438.  
  439. #if !GENERATINGCFM
  440. #pragma parameter DimmingControl(__D0)
  441. #endif
  442. extern pascal void DimmingControl(Boolean enableSleep)
  443.  FOURWORDINLINE(0x4840, 0x303C, 0x001F, 0xA09E);
  444.  
  445. #if !GENERATINGCFM
  446. #pragma parameter __D0 IsDimmingControlDisabled
  447. #endif
  448. extern pascal Boolean IsDimmingControlDisabled(void)
  449.  TWOWORDINLINE(0x7020, 0xA09E);
  450.  
  451. #if !GENERATINGCFM
  452. #pragma parameter __D0 IsAutoSlpControlDisabled
  453. #endif
  454. extern pascal Boolean IsAutoSlpControlDisabled(void)
  455.  TWOWORDINLINE(0x7021, 0xA09E);
  456. enum {
  457.     uppSleepQProcInfo = kRegisterBased
  458.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  459.          | REGISTER_RESULT_LOCATION(kRegisterD0)
  460.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(long)))
  461.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterA0, SIZE_CODE(sizeof(SleepQRecPtr))),
  462.     uppHDSpindownProcInfo = kPascalStackBased
  463.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(HDQueueElement*)))
  464. };
  465.  
  466. #if GENERATINGCFM
  467. #define NewSleepQProc(userRoutine)        \
  468.         (SleepQUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSleepQProcInfo, GetCurrentArchitecture())
  469. #define NewHDSpindownProc(userRoutine)        \
  470.         (HDSpindownUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppHDSpindownProcInfo, GetCurrentArchitecture())
  471. #else
  472. #define NewSleepQProc(userRoutine)        \
  473.         ((SleepQUPP) (userRoutine))
  474. #define NewHDSpindownProc(userRoutine)        \
  475.         ((HDSpindownUPP) (userRoutine))
  476. #endif
  477.  
  478. #if GENERATINGCFM
  479. #define CallSleepQProc(userRoutine, message, qRecPtr)        \
  480.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSleepQProcInfo, (message), (qRecPtr))
  481. #define CallHDSpindownProc(userRoutine, theElement)        \
  482.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppHDSpindownProcInfo, (theElement))
  483. #else
  484. /* (*SleepQProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  485. #define CallHDSpindownProc(userRoutine, theElement)        \
  486.         (*(userRoutine))((theElement))
  487. #endif
  488.  
  489.  
  490. #if PRAGMA_IMPORT_SUPPORTED
  491. #pragma import off
  492. #endif
  493.  
  494. #if PRAGMA_ALIGN_SUPPORTED
  495. #pragma options align=reset
  496. #endif
  497.  
  498. #ifdef __cplusplus
  499. }
  500. #endif
  501.  
  502. #endif /* __POWER__ */
  503.